<?php
ob_start();
error_reporting(0);
//error_reporting(E_ALL ^ E_NOTICE);
include_once($_SERVER['DOCUMENT_ROOT'] . '/htqlmba/models/m_mba.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/htqlmba/controls/c_mba.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <link href="/htqlmba/libraries/css/capnhatdv.css" type="text/css" rel="stylesheet">
       
        <script type="text/javascript">
		
		
            // funtion lay gia tri tu radio button "chon"
            function getValue(id) {
                // bang thong tin chinh
                document.capnhatmba.txtson0.value = document.getElementById("son0" + id).innerHTML;
                document.capnhatmba.txtcongsuat.value = document.getElementById("congsuat" + id).innerHTML;
                document.capnhatmba.txtngaychuyenden.value = document.getElementById("ngaychuyenden" + id).innerHTML;
                document.capnhatmba.txtmadienap.value = document.getElementById("madienap" + id).value;
                document.capnhatmba.txtmaloaimay.value = document.getElementById("maloai" + id).value;
                document.capnhatmba.txtmanhasx.value = document.getElementById("mansx" + id).value;
                document.capnhatmba.txtmadonvi.value = document.getElementById("madv" + id).value;
                document.capnhatmba.txttenloaidau.value = document.getElementById("tenloaidau" + id).innerHTML;
                document.capnhatmba.txtnuocsx.value = document.getElementById("tennuoc" + id).innerHTML;
                // bang thong tin chi tiet 
                document.capnhatmba.txtmsts.value = document.getElementById("msts" + id).value;
                document.capnhatmba.txtghichu.value = document.getElementById("ghichu" + id).value;
                document.capnhatmba.txtnhanxet.value = document.getElementById("nhanxet" + id).value;
                document.capnhatmba.txtngayvanhanh.value = document.getElementById("ngayvanhanh" + id).value;
                document.capnhatmba.txtngayngungvanhanh.value = document.getElementById("ngayngungvanhanh" + id).value;
                document.capnhatmba.txtmatram.value = document.getElementById("matram" + id).value;
                document.capnhatmba.txtngaydaitu.value = document.getElementById("ngaydaitu" + id).value;
                document.capnhatmba.txttinhtrangmay.value = document.getElementById("tinhtrangmay" + id).value;
                document.capnhatmba.txtngaycotinhtrang.value = document.getElementById("ngaycotinhtrang" + id).value;
                document.capnhatmba.txtdiengiaitt.value = document.getElementById("diengiaitt" + id).value;


                // ban thong tin ky thuat
                document.capnhatmba.txtchieudai.value = document.getElementById("chieudai" + id).value;
                document.capnhatmba.txtchieurong.value = document.getElementById("chieurong" + id).value;
                document.capnhatmba.txtchieucao.value = document.getElementById("chieucao" + id).value;
                document.capnhatmba.txtruotmay.value = document.getElementById("ruotmay" + id).value;
                document.capnhatmba.txtdaumay.value = document.getElementById("daumay" + id).value;
                document.capnhatmba.txtthongsodo.value = document.getElementById("thongsodo" + id).value;
                document.capnhatmba.txtnamnhapve.value = document.getElementById("namnhapve" + id).value;
                document.capnhatmba.txtnamsx.value = document.getElementById("namsx" + id).value;
                document.capnhatmba.txttong.value = document.getElementById("tonghienthi" + id).value;
                document.capnhatmba.txtsapxep.value = document.getElementById("sapxep" + id).value;

                // chuyen mau button 
                document.capnhatmba.txtson0.readOnly = true;
                document.capnhatmba.txtson0.style.backgroundColor = '#cccccc';
                document.capnhatmba.btnsuamba.disabled = false;
                document.capnhatmba.btnxoamba.disabled = false;
                document.capnhatmba.btnthemmba.disabled = true;

            }
			
            function xoadulieu() {
                document.capnhatmba.btnthemmba.disabled = false;
                document.capnhatmba.btnsuamba.disabled = true;
                document.capnhatmba.btnxoamba.disabled = true;
                document.capnhatmba.txtson0.readOnly = false;
                document.capnhatmba.txtson0.style.backgroundColor = '#ffffff';

                // bang thong tin chinh
                document.capnhatmba.txtson0.value = "";
                document.capnhatmba.txtcongsuat.value = "";
                document.capnhatmba.txtngaychuyenden.value = "";
                document.capnhatmba.txtmadienap.value = "";
                document.capnhatmba.txtmaloaimay.value = "";
                document.capnhatmba.txtmanhasx.value = "";
                document.capnhatmba.txtmadonvi.value = "";
                document.capnhatmba.txttenloaidau.value = "";
                document.capnhatmba.txttenloaidaukhac.value = "";
				document.capnhatmba.txtmadienapkhac.value = "";
				document.capnhatmba.txtmaloaimaykhac.value = "";
				document.capnhatmba.txtmanhasxkhac.value = "";
				document.capnhatmba.txtnuocsxkhac.value = "";
					
				
				
				
				
				
                // bang thong tin chi tiet 
                document.capnhatmba.txtmsts.value = "";
                document.capnhatmba.txtghichu.value = "";
                document.capnhatmba.txtnhanxet.value = "";
                document.capnhatmba.txtngayvanhanh.value = "";
                document.capnhatmba.txtngayngungvanhanh.value = "";
                document.capnhatmba.txtmatram.value = "";
                document.capnhatmba.txtngaydaitu.value = "";
                document.capnhatmba.txttinhtrangmay.value = "";
                document.capnhatmba.txtngaycotinhtrang.value = "";
                document.capnhatmba.txtdiengiaitt.value = "";


                // ban thong tin ky thuat
                document.capnhatmba.txtchieudai.value = "";
                document.capnhatmba.txtchieurong.value = "";
                document.capnhatmba.txtchieucao.value = "";
                document.capnhatmba.txtruotmay.value = "";
                document.capnhatmba.txtdaumay.value = "";
                document.capnhatmba.txtthongsodo.value = "";
                document.capnhatmba.txtnamnhapve.value = "";
                document.capnhatmba.txtnamsx.value = "";
                document.capnhatmba.txttong.value = "";
                document.capnhatmba.txtsapxep.value = "";

            }

            // fuction hien bang xac nhan truoc khi xoa don vi
            function confirmDelete() {
                if (confirm("Bạn có chắc muốn xóa máy biến áp này không? Lưu ý: tất cả các thông tin liên quan đến máy biến áp này sẽ bị xóa !")) {
                    return true;
                }
                return false;
            }



        </script>

        <!--phan khai bao cho toggler-->

        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/jquery-1.9.1.js"></script>
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.effect.js"></script>
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.effect-blind.js"></script>
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.effect-explode.js"></script>
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.effect-shake.js"></script>
         <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.effect-slide.js"></script>
        <script>
            $(function() {
                // run the currently selected effect
                function runEffect() {
                    // run the effect
                    $("#effect").toggle("slide");
                }
                ;

                function runEffect2() {
                    // get effect type from
                    var selectedEffect = "blind";
                    // run the effect
                    $("#effect2").toggle(selectedEffect);
                }
                ;
                // set effect from select menu value
                $("#thongtinchitiet").click(function() {
                    runEffect();
                    return false;
                });
                $("#thongtinkythuat").click(function() {
                    runEffect2();
                    return false;
                });
            });

        </script>
        <!--phan khai bao cho toggler-->


        <!--phan khai bao cho datepicker-->
        <link rel="stylesheet" href="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/themes/redmond/jquery-ui.css">
        <link href="../libraries/css/capnhatdv.css" rel="stylesheet" type="text/css">
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.core.js"></script>	
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.datepicker.js"></script>
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/i18n/jquery.ui.datepicker-vi.js"></script>
        <script src="/htqlmba/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.widget.js"></script>
        <script>

            $(function() {
                // bat button ngay, thang
                $(".datepicker").datepicker({
                    changeMonth: true,
                    changeYear: true
                });
                // chon ngon ngu la tieng viec
                $(".datepicker").datepicker($.datepicker.regional[ "vi" ]);
                // hieu ung slikedown
                $(".datepicker").datepicker();
                $("#slikeDown").change(function() {
                    $(".datepicker").datepicker("option", "showAnim", $(this).val());
                });
            });
            $(".datepicker").datepicker();
        </script>

        <!-- het phan khai bao cho datepicker-->
    </head>
    <body>
        <div class="bodyStyle">
            <form id="capnhatmba" name="capnhatmba" method="post" >
                <div >
                    <div class="toggoler">
                        <table width="1050" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                                <td colspan="4" class="TableHeader1" >&equiv; Thêm máy biến áp</td>
                            </tr>
                            <tr  class="TableField">
                                <td width="177" class="TableField3" >Số N0</td>
                                <td width="369" class="TableField3" ><input type="text" name="txtson0" id="txtson0" value="<?php echo $son0; ?> "><span class="error">*</span>
                                    <span class="error"><?php
                                        echo $son0Err;
                                        $madv = $_SESSION['nmadv'];
                                        $quyen = $_SESSION['quyen_byK'];
                                       /* echo "ma dv: ".$madv;
						echo "quyen: ".$quyen;*/
                                        ?></span></td>
                                <td width="143" class="TableField3">Loại điện áp (KV)</td>
                                <td width="361" class="TableField3"><select name="txtmadienap" id="txtmadienap" style="width: 143px">
                                        <option value="" selected>----</option>
                                        <?php
                                        $db = new database();
                                        $db->setQuery("SELECT * FROM loai_dien_ap");
                                        $result = $db->fetchAll();
                                        $tmp_select = "";

                                        while ($rows = mysql_fetch_array($result)) {
                                            if ($rows['MA_DIEN_AP'] == $madienap) {
                                                $tmp_select = selected;
                                            } else {
                                                $tmp_select = "";
                                            }
                                            echo "<option value=\"" . $rows['MA_DIEN_AP'] . "\" $tmp_select>" . $rows['CAP_DIEN_AP'] . "</option>";
                                        }
                                        ?>
                                    </select>
                                    khác
                                    <input name="txtmadienapkhac" type="text" id="txtmadienapkhac" value="<?php echo $txtmadienapkhac; ?>"><span class="error">*<span class="error"><?php echo $madienapErr; ?></span></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Công suất (KVA)</td>
                                <td class="TableField3"><input type="text" name="txtcongsuat" id="txtcongsuat" value="<?php echo $congsuat; ?>"><span class="error"><span class="error">*</span><?php echo $congsuatErr; ?></span></td>
                                <td class="TableField3">Loại máy</td>
                                <td class="TableField3"><select name="txtmaloaimay" id="txtmaloaimay"   style="width: 143px">
                                        <option value="" selected>----</option>
                                        <?php
                                        $db = new database();
                                        $db->setQuery("SELECT * FROM loai_may");
                                        $result = $db->fetchAll();
                                        $tmp_select = "";

                                        while ($rows = mysql_fetch_array($result)) {
                                            if ($rows['MA_LOAI'] == $maloaimay) {
                                                $tmp_select = selected;
                                            } else {
                                                $tmp_select = "";
                                            }
                                            echo "<option value=\"" . $rows['MA_LOAI'] . "\" $tmp_select>" . $rows['TEN_LOAI'] . "</option>";
                                        }
                                        ?>
                                    </select>
                                    khác
                                    <input name="txtmaloaimaykhac" type="text" id="txtmaloaimaykhac" value="<?php echo $tenloaimaykhac; ?>"><span class="error">*<span class="error"><?php echo $maloaimayErr; ?></span></span></td>
                                <!--lay ve ma dien ap tu loai dien ap duoc chon-->
                            </tr>
                            <tr>
                                <td class="TableField3">Loại dầu</td>
                                <td class="TableField3"><select name="txttenloaidau" id="txttenloaidau" style="width: 143px">
                                        <option value="" >----</option>
                                        <?php
                                        $db = new database();
                                        $db->setQuery("SELECT * FROM loai_dau");
                                        $result = $db->fetchAll();
                                        $tmp_select = "";
                                        while ($rows = mysql_fetch_array($result)) {
                                            $tmp_select = "";
                                            if ($rows['TEN_LOAI_DAU'] == $tenloaidau) {
                                                $tmp_select = selected;
                                            }
                                            echo "<option value=\"" . $rows['TEN_LOAI_DAU'] . "\"  $tmp_select>" . $rows['TEN_LOAI_DAU'] . "</option>";
                                        }
                                        ?>
                                    </select>
                                    khác
                                    <input name="txttenloaidaukhac" type="text" id="txttenloaidaukhac" value="<?php echo $tenloaidaukhac; ?>"><span class="error">*<span class="error"><?php echo $tenloaidauErr; ?></span></span></td>
                                <td class="TableField3">Nhà sản xuất</td>
                                <td class="TableField3"><select name="txtmanhasx" id="txtmanhasx" style="width: 143px">
                                        <option value="" selected>----</option>
                                        <?php
                                        $db = new database();
                                        $db->setQuery("SELECT * FROM nha_sx");
                                        $result = $db->fetchAll();
                                        $tmp_select = "";

                                        while ($rows = mysql_fetch_array($result)) {
                                            if ($rows['MA_NSX'] == $manhasx) {
                                                $tmp_select = selected;
                                            } else {
                                                $tmp_select = "";
                                            }
                                            echo "<option value=\"" . $rows['MA_NSX'] . "\" $tmp_select>" . $rows['TEN_NSX'] . "</option>";
                                        }
                                        ?>
                                    </select>
                                    khác
                                    <input name="txtmanhasxkhac" type="text" id="txtmanhasxkhac" value="<?php echo $tennhasxkhac; ?>"><span class="error">*<span class="error"><?php echo $manhasxErr; ?></span></span></td>
                            </tr>
                            <tr >
                                <td class="TableField3">Ngày chuyển đến</td>
                                <td class="TableField3" ><input name="txtngaychuyenden"  type="text"  class="datepicker" size="12" maxlength="12"  readonly="readonly"  value="<?php echo $ngaychuyenden; ?>">
                                <span class="error">*<?php echo $ngaychuyendenErr; ?></span></td>
                                <td class="TableField3">Nước sản xuất</td>
                                <td class="TableField3"><select name="txtnuocsx" id="txtnuocsx" style="width: 143px">
                                        <option value="" selected>----</option>
<?php
$db = new database();
$db->setQuery("SELECT * FROM nuoc_sx");
$result = $db->fetchAll();
$tmp_select = "";


while ($rows = mysql_fetch_array($result)) {
    if ($rows['TEN_NUOC_SX'] == $nuocsx) {
        $tmp_select = selected;
    } else {
        $tmp_select = "";
    }
    echo "<option value=\"" . $rows['TEN_NUOC_SX'] . "\" $tmp_select>" . $rows['TEN_NUOC_SX'] . "</option>";
}
?>
                                    </select>
                                    khác
                                    <input name="txtnuocsxkhac" type="text" id="txtnuocsxkhac" value="<?php echo $nuocsxkhac; ?>"><span class="error">*<span class="error"><?php echo $nuocsxErr; ?></span></span></td>
                            </tr>
                            <tr <?php if ($_SESSION['quyen_byK'] == 3) echo "style=\"display:none\""; ?>>
                              <td class="TableField3">Tên đơn vị</td>
                              <td colspan="3" class="TableField3"><select name="txtmadonvi" id="txtmadonvi"style="width: 143px">
                                <option value="" selected>----</option>
                                <?php
                                        $db = new database();
                                        $db->setQuery("SELECT don_vi.`MA_DON_VI`,don_vi.`TEN_DON_VI`,tai_khoan.quyen FROM `don_vi`,tai_khoan
WHERE don_vi.MA_DON_VI=tai_khoan.MA_DON_VI AND
tai_khoan.QUYEN=3");
                                        $result = $db->fetchAll();
                                        $tmp_select = "";

                                        while ($rows = mysql_fetch_array($result)) {
                                            if ($rows['MA_DON_VI'] == $madonvi) {
                                                $tmp_select = selected;
                                            } else {
                                                $tmp_select = "";
                                            }
                                            echo "<option value=\"" . $rows['MA_DON_VI'] . "\" $tmp_select>" . $rows['TEN_DON_VI'] . "</option>";
                                        }
                                        ?>
                              </select>
                              <span class="error">*<?php echo $tendonviErr; ?></span></td>
                            </tr>
                        </table>
                        <div style="padding-top:5px"></div>
                        <table width="1050" border="0" align="center" cellspacing="0" cellpadding="0">
                            <tr>
                                <td colspan="4" class="TableHeader1" style="cursor: pointer" id="thongtinchitiet" >&equiv; Thông tin chi tiết</td>
                            </tr>
                        </table>
                  </div>
                </div>
                <div class="toggler">
                    <div id="effect"  style="display:none"><!--style="display:none"-->
                        <table width="1050" border="0" align="center" cellspacing="0" cellpadding="0" class="toggler" >

                            <tr>
                                <td width="177" class="TableField3">MSTS</td>
                                <td width="371" class="TableField3"><input type="text" name="txtmsts" id="txtmsts" value="<?php echo $msts; ?>"><span class="error"><?php echo $mstsErr; ?></span></td>
                                <td width="141" class="TableField3">Ngày vận hành</td>
                                <td width="361" class="TableField3"><input name="txtngayvanhanh"  type="text"  class="datepicker" size="12" maxlength="12"  readonly="readonly" value="<?php echo $ngayvanhanh; ?>"> <span class="error"><?php echo $ngayvanhanhErr; ?></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Tên trạm</td>
                                <td class="TableField3"><select name="txtmatram" id="txtmatram">
                                        <option value="" selected>----</option>
<?php
$db = new database();
$db->setQuery("SELECT * FROM tram");
$result = $db->fetchAll();
$tmp_select = "";

while ($rows = mysql_fetch_array($result)) {
    if ($rows['MA_TRAM'] == $matram) {
        $tmp_select = selected;
    } else {
        $tmp_select = "";
    }
    echo "<option value=\"" . $rows['MA_TRAM'] . "\" $tmp_select>" . $rows['TEN_TRAM'] . "</option>";
}
?>
                                    </select> <span class="error"><?php echo $tentramErr; ?></span></td>
                                <td class="TableField3">Ngày ngưng vận hành</td>
                                <td class="TableField3"><input name="txtngayngungvanhanh"  type="text"  class="datepicker" size="12" maxlength="12"  readonly="readonly" value="<?php echo $ngayngungvanhanh; ?>"> <span class="error"><?php echo $ngayngungvanhanhErr; ?></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Tình trạng máy (hiện tại)</td>
                                <td class="TableField3"><select name="txttinhtrangmay" id="txttinhtrangmay">
                                        <option value="" selected>----</option>
<?php
$db = new database();
$db->setQuery("SELECT * FROM tinh_trang_may");
$result = $db->fetchAll();
$tmp_select = "";

while ($rows = mysql_fetch_array($result)) {
    if ($rows['TEN_TINH_TRANG_MAY'] == $tinhtrangmay) {
        $tmp_select = selected;
    } else {
        $tmp_select = "";
    }
    echo "<option value=\"" . $rows['TEN_TINH_TRANG_MAY'] . "\" $tmp_select>" . $rows['TEN_TINH_TRANG_MAY'] . "</option>";
}
?>
                                    </select>
                                    khác
                                    <input name="txttinhtrangmaykhac" type="text" id="txttinhtrangmaykhac" value="<?php echo $tinhtrangmaykhac; ?>"><span class="error"><?php echo $tinhtrangmayErr; ?></span></td>
                                <td class="TableField3">Ngày đại tu</td>
                                <td class="TableField3"><input name="txtngaydaitu"   class="datepicker" size="12" maxlength="12"  readonly="readonly" value="<?php echo $ngaydaitu; ?>"> <span class="error"><?php echo $ngaydaituErr; ?></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Có tình trạng từ ngày</td>
                                <td class="TableField3"><input name="txtngaycotinhtrang"  type="text"  class="datepicker" size="12" maxlength="12"  readonly="readonly" value="<?php echo $ngaycotinhtrang; ?>"><span class="error"><?php echo $ngaycotinhtrangErr; ?></span></td>
                                <td class="TableField3">Diển giải tình trạng</td>
                                <td class="TableField3"><textarea name="txtdiengiaitt" id="txtdiengiaitt" cols="40" rows="3" ><?php echo $diengiaitt; ?></textarea></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Ghi chú</td>
                                <td class="TableField3"><textarea name="txtghichu" id="txtghichu" cols="40" rows="3" ><?php echo $ghichu; ?></textarea></td>
                                <td class="TableField3">Nhận xét</td>
                                <td class="TableField3"><textarea name="txtnhanxet" id="txtnhanxet" cols="40" rows="3" ><?php echo $nhanxet; ?></textarea></td>
                            </tr>
                        </table>
                    </div>
                </div>

                <table width="1050" border="0" align="center" cellspacing="0" cellpadding="0">
                    <tr>
                        <td colspan="4" class="TableHeader1" style="cursor: pointer" id="thongtinkythuat" > &equiv; Thông tin kỹ thuật</td>
                    </tr>
                </table>
                <div class="toggler" >
                    <div id="effect2"  style="display:none"><!--style="display:none"-->
                        <table width="1050" border="0" align="center" cellspacing="0" cellpadding="0" >
                            <tr>
                                <td width="177" class="TableField3">Chiều dài (mm)</td>
                                <td width="363" class="TableField3"><input type="text" name="txtchieudai" id="txtchieudai" value="<?php echo $chieudai; ?>"><span class="error"><?php echo $chieudaiErr; ?></span></td>
                                <td width="191" class="TableField3">Ruột máy (kg)</td>
                                <td width="319" class="TableField3"><input type="text" name="txtruotmay" id="txtruotmay" value="<?php echo $ruotmay; ?>"><span class="error"><?php echo $ruotmayErr; ?></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Chiều rộng (mm)</td>
                                <td class="TableField3"><input type="text" name="txtchieurong" id="txtchieurong" value="<?php echo $chieurong; ?>"><span class="error"><?php echo $chieurongErr; ?></span></td>
                                <td class="TableField3">Đầu máy (kg)</td>
                                <td class="TableField3"><input type="text" name="txtdaumay" id="txtdaumay" value="<?php echo $daumay; ?>"><span class="error"><?php echo $daumayErr; ?></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Chiều cao (mm)</td>
                                <td class="TableField3"><input type="text" name="txtchieucao" id="txtchieucao" value="<?php echo $chieucao; ?>"><span class="error"><?php echo $chieucaoErr; ?></span></td>
                                <td class="TableField3">Tổng (kg)</td>
                                <td class="TableField3"><input type="text" name="txttong" id="txttong" value="<?php echo $tong; ?>"><span class="error"><?php echo $tongErr; ?></span></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Năm nhập về</td>
                                <td class="TableField3"><select name="txtnamnhapve" id="select13">
                                        <option value="" selected>----</option>
                                        <?php
                                        $tmp_select = "";

                                        for ($n = 1900; $n < 2090; $n++) {
                                            if ($n == $namnhapve) {
                                                $tmp_select = selected;
                                            } else {
                                                $tmp_select = "";
                                            }

                                            echo "<option value=\"" . $n . "\" $tmp_select>" . $n . "</option>";
                                        }
                                        ?>
                                    </select><span class="error"><?php echo $namnhapveErr; ?></span></td>
                                <td class="TableField3">Thông số đo</td>
                                <td class="TableField3"><input type="text" name="txtthongsodo" id="txtthongsodo" value="<?php echo $thongsodo; ?>"></td>
                            </tr>
                            <tr>
                                <td class="TableField3">Năm sản xuất</td>
                                <td class="TableField3"><select name="txtnamsx" id="txtnamsx">
                                        <option value="" selected>----</option>
<?php
$tmp_select = "";
for ($n = 1900; $n < 2090; $n++) {
    if ($n == $namsx) {
        $tmp_select = selected;
    } else {
        $tmp_select = "";
    }
    echo "<option value=\"" . $n . "\" $tmp_select>" . $n . "</option>";
}
?>
                                    </select><span class="error"><?php echo $namsxErr; ?></span></td>
                                <td class="TableField3">&nbsp;</td>
                                <td class="TableField3"><label for="txtsapxep"></label>
                                    <input type="text" name="txtsapxep" id="txtsapxep" style="display:none" /></td>
                            </tr>
                        </table>
                    </div>
                    <p>&nbsp;</p>
                </div>
                <div class="btn_x">
                    <p align="center">
                        <input type="submit" name="btnthemmba" id="btnthemmba" value="Thêm máy biến áp" onClick=" getValue()">
                        <input type="button" name="btnreset" id="btnreset" value="Xóa dử liệu nhập vào" onClick="xoadulieu()">
                        <input type="submit" name="btnsuamba" id="btnsuamba" value="Sửa máy biến áp" >
                        <input type="submit" name="btnxoamba" id="btnxoamba" value="Xóa máy biến áp" disabled="true" onClick="return confirmDelete()">
                    </p>

                </div>
                <div >
                  <table width="448" border="0" class="FindMBAStyle">
                    <tr>
                      <th colspan="2" scope="col" class="TableHeader1">Chọn máy biến áp bằng số N0 </th>
                    </tr>
                    <tr>
                      <th width="201" scope="col" ><input name="txtson0_input" type="text" id="txtson0_input" size="40"></th>
                      <th width="290" scope="col"><input type="submit" name="btnChonN0" id="btnChonN0" value="Chọn máy biến áp theo số N0"></th>
                    </tr>
                  </table>
                  <span  class="FindMBAStyleErr"> <?php echo $findreport;?> </span>
                </div>
                <p>&nbsp;</p>
                <div >
                    <!-- lay du lieu tu bang don vi va hien thi -->
                    <?php
                    $mba = new MBA();
                    $rowperpage = 15;
                    if (!isset($_GET['page'])) {
                        $_GET['page'] = 1;
                    }

                    $vitri = ($_GET['page'] - 1) * $rowperpage;

                    if ($_SESSION['quyen_byK'] == 3) {
                        $result = $mba->dsMBA2($vitri, $rowperpage);
                        $result_4paging = $mba->dsMBA4();
                    } else {
                        $result = $mba->dsMBA($vitri, $rowperpage);
                        $result_4paging = $mba->dsMBA3();
                    }



                    $n_4paging = mysql_num_rows($result_4paging);
                    $tong_so_trang = floor($n_4paging / $rowperpage) + 1;

                    echo "<table align='center' width='1050' border='0' cellspacing='0' cellpadding='0' >";
                    echo "<tr >";
                    echo "<td align='center' class='TableHeader1'> &equiv; Danh sách máy biến áp</td>";
                    echo "</tr>";
                    echo "<tr >";
                    echo "<td colspan='3' valign='top'><table width='1050' border='0' cellpadding='0' cellspacing='0'>";
                    echo "<tr>";
                    echo "<td width='30' align='center' class='TableHeader' >STT</td>";
                    echo "<td width='30' align='center' class='TableHeader' >Số N0</td>";
                    echo "<td width='400' align='center' class='TableHeader' >Loại điện áp </td>";
                    echo "<td width='200' align='center' class='TableHeader' >Công suất </td>";
                    echo "<td width='200' align='center' class='TableHeader'>Loại máy </td>";
                    echo "<td width='600' align='center' class='TableHeader'>Loại dầu </td>";
                    echo "<td width='600' align='center' class='TableHeader'>Nhà sản xuất </td>";
                    echo "<td width='600' align='center' class='TableHeader'>Tên đơn vị </td>";
                    echo "<td width='250' align='center' class='TableHeader'>Nước sản xuất </td>";
                    echo "<td width='250' align='center' class='TableHeader'>Ngày chuyển đến</td>";
           
					
                    echo "</tr>";
                    $num = mysql_num_rows($result_4paging);

                    $i = 0;
                    echo "<tbody style='display:none;'>";
                    while ($row = mysql_fetch_array($result)) {

                        $i++;
                        if ($i % 2 == 0) {
                            echo "</tbody>";
                            echo "<tr onClick='getValue($i);'>";
                            echo "<td align='center' class='TableField2'>" . $i . "</td>";
                            echo "<td  align='center' class='TableField2'><div id='son0$i'>" . $row['SO_N0'] . "</div></td>";
                            echo "<td  align='left' class='TableField2'><div id='capdienap$i'>" . $row['CAP_DIEN_AP'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='madienap$i' value='" . $row['MA_DIEN_AP'] . "' />";
                            echo "<td  align='left' class='TableField2'><div id='congsuat$i'>" . $row['CONG_SUAT'] . "</div></td>";
                            echo "<td  align='left' class='TableField2'><div id='tenloai$i'>" . $row['TEN_LOAI'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='maloai$i' value='" . $row['MA_LOAI'] . "' />";
                            echo "<td  align='left' class='TableField2'><div id='tenloaidau$i'>" . $row['TEN_LOAI_DAU'] . "</div></td>";
                            echo "<td  align='left' class='TableField2'><div id='tennsx$i'>" . $row['TEN_NSX'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='mansx$i' value='" . $row['MA_NSX'] . "' />";
                            echo "<td  align='left' class='TableField2'><div id='tendonvi$i'>" . $row['TEN_DON_VI'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='madv$i' value='" . $row['MA_DON_VI'] . "' />";
                            echo "<td  align='left' class='TableField2'><div id='tennuoc$i'>" . $row['TEN_NUOC'] . "</div></td>";
                            echo "<td  align='left' class='TableField2'><div id='ngaychuyenden$i'>" . $row['NGAY_CHUYEN_DEN2'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='msts$i' value='" . $row['MSTS'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='chieudai$i' value='" . $row['CHIEU_DAI'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='chieurong$i' value='" . $row['CHIEU_RONG'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='chieucao$i' value='" . $row['CHIEU_CAO'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ruotmay$i' value='" . $row['RUOT_MAY'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='daumay$i' value='" . $row['DAU_MAY'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='thongsodo$i' value='" . $row['THONG_SO_DO'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='namnhapve$i' value='" . $row['NAM_NHAP_VE'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='tonghienthi$i' value='" . $row['TONG'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='namsx$i' value='" . $row['NAM_SX'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ghichu$i' value='" . $row['GHI_CHU'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='nhanxet$i' value='" . $row['NHAN_XET'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngayvanhanh$i' value='" . $row['NGAY_VAN_HANH2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngayngungvanhanh$i' value='" . $row['NGAY_NGUNG_VAN_HANH2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='matram$i' value='" . $row['MA_TRAM'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngaydaitu$i' value='" . $row['NGAY_DAI_TU2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='tinhtrangmay$i' value='" . $row['TEN_TINH_TRANG_MAY'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngaycotinhtrang$i' value='" . $row['TINH_TRANG_NGAY2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='diengiaitt$i' value='" . $row['DG_TINH_TRANG'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='sapxep$i' value='" . $row['SAP_XEP'] . "' />";
                            
                            echo "</tr>";
                        } else {
                            echo "</tbody>";
                            echo "<tr onClick='getValue($i);'>";
                            echo "<td align='center' class='TableField'>" . $i . "</td>";
                            echo "<td  align='center' class='TableField'><div id='son0$i'>" . $row['SO_N0'] . "</div></td>";
                            echo "<td  align='left' class='TableField'><div id='capdienap$i'>" . $row['CAP_DIEN_AP'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='madienap$i' value='" . $row['MA_DIEN_AP'] . "' />";
                            echo "<td  align='left' class='TableField'><div id='congsuat$i'>" . $row['CONG_SUAT'] . "</div></td>";
                            echo "<td  align='left' class='TableField'><div id='tenloai$i'>" . $row['TEN_LOAI'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='maloai$i' value='" . $row['MA_LOAI'] . "' />";
                            echo "<td  align='left' class='TableField'><div id='tenloaidau$i'>" . $row['TEN_LOAI_DAU'] . "</div></td>";
                            echo "<td  align='left' class='TableField'><div id='tennsx$i'>" . $row['TEN_NSX'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='mansx$i' value='" . $row['MA_NSX'] . "' />";
                            echo "<td  align='left' class='TableField'><div id='tendonvi$i'>" . $row['TEN_DON_VI'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='madv$i' value='" . $row['MA_DON_VI'] . "' />";
                            echo "<td  align='left' class='TableField'><div id='tennuoc$i'>" . $row['TEN_NUOC'] . "</div></td>";
                            echo "<td  align='left' class='TableField'><div id='ngaychuyenden$i'>" . $row['NGAY_CHUYEN_DEN2'] . "</div></td>";
                            echo "<input type='hidden' name='hiddenField' id='msts$i' value='" . $row['MSTS'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='chieudai$i' value='" . $row['CHIEU_DAI'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='chieurong$i' value='" . $row['CHIEU_RONG'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='chieucao$i' value='" . $row['CHIEU_CAO'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ruotmay$i' value='" . $row['RUOT_MAY'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='daumay$i' value='" . $row['DAU_MAY'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='thongsodo$i' value='" . $row['THONG_SO_DO'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='tonghienthi$i' value='" . $row['TONG'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='namnhapve$i' value='" . $row['NAM_NHAP_VE'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='namsx$i' value='" . $row['NAM_SX'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ghichu$i' value='" . $row['GHI_CHU'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='nhanxet$i' value='" . $row['NHAN_XET'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngayvanhanh$i' value='" . $row['NGAY_VAN_HANH2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngayngungvanhanh$i' value='" . $row['NGAY_NGUNG_VAN_HANH2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='matram$i' value='" . $row['MA_TRAM'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngaydaitu$i' value='" . $row['NGAY_DAI_TU2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='tinhtrangmay$i' value='" . $row['TEN_TINH_TRANG_MAY'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='ngaycotinhtrang$i' value='" . $row['TINH_TRANG_NGAY2'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='diengiaitt$i' value='" . $row['DG_TINH_TRANG'] . "' />";
                            echo "<input type='hidden' name='hiddenField' id='sapxep$i' value='" . $row['SAP_XEP'] . "' />";

                           
                            echo "</tr>";
                        }
                    }
                    echo "</tbody>";

                    echo "<tr>";
                    echo "<td align='left' colspan='9'><span style=' color:#008000'>Tổng số MBA: $num";
                    echo "</span></td>";
                    echo "<br>";
                    echo "<td align='right' colspan='2'><font color='green'>";
                    echo "</font></td>";
                    echo "</tr>";
                    echo "</table></td>";
                    echo "</tr>";
                    echo "</table>";
                    //}
//}			
                    echo "<span style=' color:#008000'>Tổng số trang: " . $tong_so_trang;
                    echo "</span>";
                    echo "<br>";
                    echo "<br>";
                    if ($_GET['page'] > 1) {
                        echo '<a href="index.php?content=qlmba&page=' . ($_GET['page'] - 1) . '">Trước</a> ';
                    }
                    for ($i = 1; $i <= $tong_so_trang; $i++) {
                        if ($i == $_GET['page']) {
                            echo '&nbsp;[' . $i . ']&nbsp;';
                        } else {
                            echo '<a href="index.php?content=qlmba&page=' . $i . '">' . $i . '</a> ';
                        }
                    }
                    if ($_GET['page'] < $tong_so_trang) {
                        echo ' <a href="index.php?content=qlmba&page=' . ($_GET['page'] + 1) . '">Sau</a>';
                    }
                    ?>
                    
            </form>
            <!-- het bang -->
        </form>
